package io.admin.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.admin.common.constant.Constant;
import io.admin.common.page.PageData;
import io.admin.common.service.impl.CrudServiceImpl;
import io.admin.modules.security.user.SecurityUser;
import io.admin.modules.security.user.UserDetail;
import io.admin.modules.sys.dao.UserEquipmentDao;
import io.admin.modules.sys.dto.SysUserDTO;
import io.admin.modules.sys.dto.UserEquipmentDTO;
import io.admin.modules.sys.entity.SysUserEntity;
import io.admin.modules.sys.entity.UserEntity;
import io.admin.modules.sys.entity.UserEquipmentEntity;
import io.admin.modules.sys.enums.SuperAdminEnum;
import io.admin.modules.sys.service.UserEquipmentService;
import cn.hutool.core.util.StrUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 用户设备管理
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2024-07-04
 */
@Service
public class UserEquipmentServiceImpl extends CrudServiceImpl<UserEquipmentDao, UserEquipmentEntity, UserEquipmentDTO> implements UserEquipmentService {
    @Autowired
    private UserEquipmentDao userEquipmentDao;

    @Override
    public PageData<UserEquipmentDTO> page(Map<String, Object> params) {
        //转换成like
        paramsToLike(params, "username");
        paramsToLike(params, "mobile");
        paramsToLike(params, "bumber");
        //分页
        IPage<UserEquipmentEntity> page = getPage(params, Constant.CREATE_DATE, false);
        //查询
        List<UserEquipmentEntity> list = baseDao.getList(params);
        return getPageData(list, page.getTotal(), UserEquipmentDTO.class);
    }

    @Override
    public QueryWrapper<UserEquipmentEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        QueryWrapper<UserEquipmentEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StrUtil.isNotBlank(id), "id", id);
        return wrapper;
    }


}